home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / mee / vbdao / visdata / snapgrid.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-06  |  19.2 KB  |  639 lines

  1. VERSION 2.00
  2. Begin Form fGridFrmSS 
  3.    BackColor       =   &H00C0C0C0&
  4.    ClientHeight    =   3105
  5.    ClientLeft      =   930
  6.    ClientTop       =   3585
  7.    ClientWidth     =   6690
  8.    Height          =   3510
  9.    Icon            =   0
  10.    Left            =   870
  11.    LinkTopic       =   "Form1"
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   3096
  14.    ScaleMode       =   0  'User
  15.    ScaleWidth      =   6708
  16.    Tag             =   "Dynaset"
  17.    Top             =   3240
  18.    Width           =   6810
  19.    Begin Grid cGrid 
  20.       FixedCols       =   0
  21.       FixedRows       =   0
  22.       Height          =   2412
  23.       Left            =   0
  24.       TabIndex        =   0
  25.       Top             =   480
  26.       Width           =   6732
  27.    End
  28.    Begin PictureBox ViewButtons 
  29.       BackColor       =   &H00C0C0C0&
  30.       BorderStyle     =   0  'None
  31.       Height          =   375
  32.       Left            =   0
  33.       ScaleHeight     =   372
  34.       ScaleMode       =   0  'User
  35.       ScaleWidth      =   5171.606
  36.       TabIndex        =   1
  37.       Top             =   24
  38.       Width           =   5175
  39.       Begin CommandButton SortButton 
  40.          Caption         =   "&Sort"
  41.          Height          =   372
  42.          Left            =   3720
  43.          TabIndex        =   9
  44.          Top             =   0
  45.          Width           =   612
  46.       End
  47.       Begin CommandButton FilterButton 
  48.          Caption         =   "Fil&ter"
  49.          Height          =   372
  50.          Left            =   3120
  51.          TabIndex        =   8
  52.          Top             =   0
  53.          Width           =   612
  54.       End
  55.       Begin CommandButton RefreshButton 
  56.          Caption         =   "&Redo"
  57.          Height          =   372
  58.          Left            =   2520
  59.          TabIndex        =   7
  60.          Top             =   0
  61.          Width           =   612
  62.       End
  63.       Begin CommandButton CloseButton 
  64.          Cancel          =   -1  'True
  65.          Caption         =   "&Close"
  66.          Height          =   372
  67.          Left            =   4320
  68.          TabIndex        =   6
  69.          Top             =   0
  70.          Width           =   612
  71.       End
  72.       Begin CommandButton MoreButton 
  73.          Caption         =   "&More"
  74.          Height          =   372
  75.          Left            =   1320
  76.          TabIndex        =   5
  77.          Top             =   0
  78.          Width           =   612
  79.       End
  80.       Begin CommandButton NextButton 
  81.          Caption         =   "&Next"
  82.          Height          =   372
  83.          Left            =   120
  84.          TabIndex        =   4
  85.          Top             =   0
  86.          Width           =   612
  87.       End
  88.       Begin CommandButton FirstButton 
  89.          Caption         =   "&First"
  90.          Height          =   372
  91.          Left            =   720
  92.          TabIndex        =   3
  93.          Top             =   0
  94.          Width           =   612
  95.       End
  96.       Begin CommandButton FindButton 
  97.          Caption         =   "F&ind"
  98.          Height          =   372
  99.          Left            =   1920
  100.          TabIndex        =   2
  101.          Top             =   0
  102.          Width           =   612
  103.       End
  104.    End
  105. Option Explicit
  106. 'form variables
  107. Dim FDS As Snapshot        'current form's snapshot
  108. Dim FDynSt As String       'dynaset open string
  109. Dim FTblName As String     'form dynaset table name
  110. Dim FCurrentRow As Long    'current row in dynaset
  111. Dim FGridRow As Integer    'current grid row
  112. Dim FNotFound As Integer   'find not found flag
  113. Dim FFindForm As New fFind 'find form
  114. Dim FNumbRows As Long      'total number of rows in table
  115. Dim FDynaString As String  'dynaset open string
  116. Sub cGrid_DblClick ()
  117.   Dim r As Integer       'return from execute sql
  118.   Dim fn As String       'field name
  119.   Dim bm As String
  120.   Dim c As Integer
  121.   On Error GoTo ZoomErr
  122.   r = cGrid.Row
  123.   cGrid.Row = 0
  124.   'get field name
  125.   fn = cGrid.Text
  126.   cGrid.Row = r
  127.   'only allow memo fields for browsing
  128.   If FDS(fn).Type <> FT_MEMO Then
  129.     Exit Sub
  130.   End If
  131.   'make sure it's a string or memo field
  132.   If FDS(fn).Type <> FT_BINARY Then
  133.      gstZoomData = cGrid.Text
  134.      fZoom.caption = fn
  135.      fZoom.Top = VDMDI.Top + Top + 1200
  136.      fZoom.Left = VDMDI.Left + Left + 250
  137.      If FDS(fn).Type <> FT_MEMO Then
  138.        fZoom.cData = gstZoomData
  139.        fZoom.Height = 1125
  140.      Else
  141.        fZoom.cMemo = gstZoomData
  142.        fZoom.cMemo.Visible = True
  143.        fZoom.cData.Visible = False
  144.        fZoom.Height = 2205
  145.      End If
  146.      fZoom.CloseZoomButton.Visible = True
  147.      fZoom.Show MODAL
  148.   End If
  149.   GoTo ZoomEnd
  150. ZoomErr:
  151.   ShowError
  152.   Resume ZoomEnd
  153. ZoomEnd:
  154. End Sub
  155. Sub cGrid_KeyUp (KeyCode As Integer, Shift As Integer)
  156.   'zoom on F4 key press
  157.   If KeyCode = &H73 Then   'F4
  158.     cGrid_DblClick
  159.   End If
  160. End Sub
  161. Sub CloseButton_Click ()
  162.   Unload Me
  163. End Sub
  164. Sub FilterButton_Click ()
  165.   On Error GoTo FilterErr
  166.   Dim ds1 As Snapshot, ds2 As Snapshot
  167.   Dim FilterStr As String
  168.   Dim numbrows As Long    'local number of rows
  169.   Set ds1 = FDS            'save the dynaset
  170.   FilterStr = InputBox("Enter Filter Expression:")
  171.   If Len(FilterStr) = 0 Then Exit Sub
  172.   FDS.Filter = FilterStr
  173.   Set ds2 = FDS.CreateSnapshot()            'establish the filter
  174.   Set FDS = ds2            'assign back to original dynaset object
  175.   'everything must be okay so redisplay form on 1st record
  176.   FNumbRows = GetNumbRecsSS(FDS)          'query numb of recs
  177.    If FNumbRows = -1 Then
  178.      'error occurred but go on anyway
  179.      'because row count is non-critical
  180.      caption = "SnapShot: " & FTblName
  181.      numbrows = gwMaxGridRows
  182.      FCurrentRow = numbrows
  183.    ElseIf FNumbRows = 0 Then
  184.      Beep
  185.      MsgBox "No Records found!", 48
  186.      ResetMouse Me
  187.      Unload Me
  188.      Exit Sub
  189.    ElseIf FNumbRows > gwMaxGridRows Then
  190.      caption = "SnapShot: " & FTblName & " [" & CStr(FNumbRows) & " total rows]"
  191.      numbrows = gwMaxGridRows
  192.      FCurrentRow = numbrows
  193.    Else
  194.      numbrows = FNumbRows
  195.      caption = "SnapShot: " & FTblName & " [" & CStr(FNumbRows) & " rows]"
  196.    End If
  197.   If LoadGridSS(cGrid, FDS, FDynSt, numbrows, 0) = False Then
  198.     Unload Me
  199.     Exit Sub
  200.   End If
  201.   GoTo FilterEnd
  202. FilterErr:
  203.   ShowError
  204.   Set FDS = ds1            're-assign back to original
  205.   Resume FilterEnd
  206. FilterEnd:
  207. End Sub
  208. Sub FindButton_Click ()
  209.    Dim i As Integer, r As Integer, c As Integer
  210.    On Error GoTo FindErr
  211.    'load the column names into the find form
  212.    'the 1st time it is loaded
  213.    If FFindForm.cFieldList.ListCount = 0 Then
  214.      FFindForm.cFieldList.Clear
  215.      r = cGrid.Row
  216.      c = cGrid.Col
  217.      cGrid.Row = 0
  218.      cGrid.Col = 0
  219.      For i = 1 To cGrid.Cols - 1
  220.        cGrid.Col = cGrid.Col + 1
  221.        FFindForm.cFieldList.AddItem cGrid.Text
  222.      Next
  223.      cGrid.Row = r
  224.      cGrid.Col = c
  225.    End If
  226. FindStart:       'used to loop around on not found
  227.    'reset the flags
  228.    gfFindFailed = False
  229.    gfFromTableView = True
  230.    MsgBar "Enter Search Parameters", False
  231.    FFindForm.Show MODAL
  232.    MsgBar "Searching for record", True
  233.    If gfFindFailed = True Then Exit Sub
  234.    FNotFound = False
  235.    SetHourglass Me
  236.    'search for the record
  237.    cGrid.SetFocus        'start at the top
  238.    SendKeys "^{Home}"
  239.    cGrid.Col = 1
  240.    cGrid.Row = 0
  241.    'move the right column
  242.    While cGrid.Text <> UCase(gstFindField)
  243.      If cGrid.Col = cGrid.Cols Then 'reached max col
  244.      Else
  245.        cGrid.Col = cGrid.Col + 1
  246.        SendKeys "{Right}"
  247.      End If
  248.    Wend
  249.    cGrid.Row = 1
  250.    While cGrid.Row < cGrid.Rows - 1
  251.        If gfFindMatch = False Then
  252.          Select Case gstFindOp
  253.            Case "="
  254.              If UCase(cGrid.Text) = UCase(gstFindExpr) Then GoTo AfterWhile
  255.            Case "<>"
  256.              If UCase(cGrid.Text) <> UCase(gstFindExpr) Then GoTo AfterWhile
  257.            Case ">="
  258.              If UCase(cGrid.Text) >= UCase(gstFindExpr) Then GoTo AfterWhile
  259.            Case "<="
  260.              If UCase(cGrid.Text) <= UCase(gstFindExpr) Then GoTo AfterWhile
  261.            Case ">"
  262.              If UCase(cGrid.Text) > UCase(gstFindExpr) Then GoTo AfterWhile
  263.            Case "<"
  264.              If UCase(cGrid.Text) < UCase(gstFindExpr) Then GoTo AfterWhile
  265.            Case "Like"
  266.              If UCase(cGrid.Text) Like UCase(gstFindExpr) Then GoTo AfterWhile
  267.          End Select
  268.        Else
  269.          Select Case gstFindOp
  270.            Case "="
  271.              If cGrid.Text = gstFindExpr Then GoTo AfterWhile
  272.            Case "<>"
  273.              If cGrid.Text <> gstFindExpr Then GoTo AfterWhile
  274.            Case ">="
  275.              If cGrid.Text >= gstFindExpr Then GoTo AfterWhile
  276.            Case "<="
  277.              If cGrid.Text <= gstFindExpr Then GoTo AfterWhile
  278.            Case ">"
  279.              If cGrid.Text > gstFindExpr Then GoTo AfterWhile
  280.            Case "<"
  281.              If cGrid.Text < gstFindExpr Then GoTo AfterWhile
  282.            Case "Like"
  283.              If cGrid.Text Like gstFindExpr Then GoTo AfterWhile
  284.          End Select
  285.        End If
  286.      cGrid.Row = cGrid.Row + 1
  287.      SendKeys "{Down}"
  288.    Wend
  289.    FNotFound = True       'didn't find it
  290. AfterWhile:
  291.    ResetMouse Me
  292.    'show the first record
  293.    If FNotFound Then
  294.      Beep
  295.      MsgBox "Record Not Found", 48
  296.      GoTo FindStart
  297.    End If
  298.    DoEvents
  299.    cGrid.SelStartRow = cGrid.Row
  300.    cGrid.SelStartCol = 1
  301.    cGrid.SelEndRow = cGrid.Row
  302.    cGrid.SelEndCol = FDS.Fields.Count
  303.    GoTo FindEnd
  304. FindErr:
  305.    ResetMouse Me
  306.    ShowError
  307.    Resume FindEnd
  308. FindEnd:
  309.    MsgBar NULL_STR, False
  310. End Sub
  311. Sub FirstButton_Click ()
  312.    Dim numbrows As Long         'number of rows
  313.    On Error GoTo GoFirstError
  314.    SetHourglass Me
  315.    MsgBar "Going to first record", True
  316.    cGrid.SetFocus
  317.    cGrid.Row = 1
  318.    cGrid.Col = 0
  319.    'get current starting row in grid
  320.    If cGrid.Text <> "1" Then
  321.      FDS.Close
  322.      Set FDS = gCurrentDB.CreateSnapshot(FDS.Name)
  323.      FNumbRows = GetNumbRecsSS(FDS)
  324.      If FNumbRows > gwMaxGridRows Then
  325.        numbrows = gwMaxGridRows
  326.        FCurrentRow = numbrows
  327.      Else
  328.        numbrows = FNumbRows
  329.      End If
  330.      If LoadGridSS(cGrid, FDS, FDynSt, numbrows, 0) = False Then
  331.        Unload Me
  332.        Exit Sub
  333.      End If
  334.   End If
  335.   cGrid.Col = 1
  336.   SendKeys "{Home}"
  337.   GoTo GoFirstEnd
  338. GoFirstError:
  339.   ShowError
  340.   Resume GoFirstEnd
  341. GoFirstEnd:
  342.   ResetMouse Me
  343.   MsgBar NULL_STR, False
  344. End Sub
  345. Sub Form_Load ()
  346.    Dim t As TableDef       'local table structure
  347.    Dim sp As Integer       'starting point of table name
  348.    Dim ep As Integer       'ending point of table name
  349.    Dim wh As String        'where clause
  350.    Dim i As Integer, j As Integer
  351.    Dim fn As String        'field name
  352.    Dim rc As Integer       'record count
  353.    Dim numbrows As Long    'local number of rows
  354.    Dim qd As QueryDef      'querydef for parameterized query
  355.    Dim p_query As Integer  'param query flag
  356.    Dim p_val As String     'param value
  357.    Dim Start1, Finish1, Start2, Finish2
  358.    On Error GoTo DynasetErr
  359.    SetHourglass Me
  360.    MsgBar "Opening Snapshot", True
  361.    'assign the temp string with the select statement
  362.    'if it is not empty, otherwise, use the table list name
  363.    If gfFromSQL = True Then
  364.      If Len(gstDynaString) = 0 Then
  365.        FDynSt = fSQL.cSQLStatement
  366.      Else
  367.        FDynSt = gstDynaString
  368.      End If
  369.    Else
  370.      FDynSt = fTables.cTableList
  371.    End If
  372.    'check for parameters
  373.    If InStr(FDynSt, "PARAM1") > 0 Or InStr(gstDynaString, "PARAM1") > 0 Then
  374.      'figure out if it is a saved querydef
  375.      If Mid(UCase(FDynSt), 1, 7) = "SELECT " Then
  376.        Set qd = gCurrentDB.CreateQueryDef("temp_qd", FDynSt)
  377.        p_query = 1
  378.      Else
  379.        Set qd = gCurrentDB.OpenQueryDef(fTables.cTableList)
  380.        p_query = 2
  381.      End If
  382.      'get the parameter value(s)
  383.      For i = 1 To 4
  384.        p_val = ""
  385.        p_val = InputBox("Enter the value for parameter " & i)
  386.        Select Case i
  387.          Case 1
  388.            qd!PARAM1 = p_val
  389.          Case 2
  390.            qd!PARAM2 = p_val
  391.          Case 3
  392.            qd!PARAM3 = p_val
  393.          Case 4
  394.            qd!PARAM4 = p_val
  395.        End Select
  396.        If InStr(FDynSt, "PARAM" & i + 1) = 0 And InStr(gstDynaString, "PARAM" & i + 1) = 0 Then Exit For
  397.      Next
  398.    End If
  399.    'attemp to open the dynaset
  400.    Start1 = TimeGetTime()
  401.    If UCase(FDynSt) = "LISTTABLES" Then
  402.      Set FDS = gCurrentDB.ListTables()
  403.    Else
  404.      If gfFromSQL = True Then
  405.        If VDMDI.cPassThru.Visible = True And VDMDI.cPassThru = 1 Then
  406.          Set FDS = gCurrentDB.CreateSnapshot(FDynSt, VBDA_SQLPASSTHROUGH)
  407.        Else
  408.          Set FDS = gCurrentDB.CreateSnapshot(FDynSt)
  409.        End If
  410.      Else
  411.        If p_query = 0 Then
  412.          If VDMDI.cPassThru.Visible = True And VDMDI.cPassThru = 1 Then
  413.            FDynSt = "select * from " & StripOwner(FDynSt)
  414.            Set FDS = gCurrentDB.CreateSnapshot(FDynSt, VBDA_SQLPASSTHROUGH)
  415.          Else
  416.            Set FDS = gCurrentDB.CreateSnapshot(FDynSt)
  417.          End If
  418.        Else
  419.          Set FDS = qd.CreateSnapshot()
  420.          qd.Close
  421.          If p_query = 1 Then gCurrentDB.DeleteQueryDef "temp_qd"
  422.        End If
  423. '       Set FDS = gCurrentDB.CreateSnapshot(FDynSt)
  424.      End If
  425.    End If
  426.    Finish1 = TimeGetTime()
  427.    Start2 = TimeGetTime()
  428.    'parse off table name to store in global gstTblName
  429.    wh = NULL_STR
  430.    sp = InStr(1, UCase(FDynSt), "FROM")
  431.    If sp > 0 Then
  432.      'must be a "select from" statement
  433.      sp = sp + 5
  434.      For ep = sp To Len(FDynSt)
  435.        'search for a space or the end of FDynSt
  436.        If Mid$(FDynSt, ep, 1) = " " Then
  437.          'get where clause if there is one
  438.          wh = Mid$(FDynSt, sp, Len(FDynSt) - sp + 1)
  439.          Exit For
  440.        End If
  441.      Next
  442.      FTblName = UCase(Mid$(FDynSt, sp, ep - sp))
  443.      If Len(wh) = 0 Then wh = FTblName
  444.    Else
  445.      'must be a table name only
  446.      FTblName = UCase(FDynSt)
  447.      wh = FTblName
  448.    End If
  449.    FDynaString = wh
  450.    'show the first record
  451.    FNumbRows = GetNumbRecsSS(FDS)          'query numb of recs
  452.    If FNumbRows = -1 Then
  453.      'error occurred but go on anyway
  454.      'because row count is non-critical
  455.      caption = "SnapShot: " & FTblName
  456.      numbrows = gwMaxGridRows
  457.      FCurrentRow = numbrows
  458.    ElseIf FNumbRows = 0 Then
  459.      Beep
  460.      MsgBox "No Records found!", 48
  461.      ResetMouse Me
  462.      Unload Me
  463.      Exit Sub
  464.    ElseIf FNumbRows > gwMaxGridRows Then
  465.      caption = "SnapShot: " & FTblName & " [" & CStr(FNumbRows) & " total rows]"
  466.      numbrows = gwMaxGridRows
  467.      FCurrentRow = numbrows
  468.    Else
  469.      numbrows = FNumbRows
  470.      caption = "SnapShot: " & FTblName & " [" & CStr(FNumbRows) & " rows]"
  471.    End If
  472.    If LoadGridSS(cGrid, FDS, FDynSt, numbrows, 0) = False Then
  473.      Unload Me
  474.      Exit Sub
  475.    End If
  476.    Height = 3800
  477.    Width = 5300
  478.    Left = 1000
  479.    Top = 1000
  480.    Finish2 = TimeGetTime()
  481.    If VDMDI.PrefShowPerf.Checked Then
  482.      Me.Show
  483.      MsgBox FNumbRows & " rows found in " & (Finish1 - Start1) / 1000 & " seconds!" & Chr(13) & Chr(10) & (Finish2 - Start2) / 1000 & " seconds to Load Grid!", 48
  484.    End If
  485.    GoTo OkayEnd
  486. DynasetErr:
  487.    If p_query = 1 Then
  488.      gCurrentDB.DeleteQueryDef "temp_qd"
  489.    End If
  490.    ShowError
  491.    ResetMouse Me
  492.    MsgBar NULL_STR, False
  493.    Unload Me
  494.    Exit Sub
  495.    Resume OkayEnd
  496. OkayEnd:
  497.    ResetMouse Me
  498.    MsgBar NULL_STR, False
  499. End Sub
  500. Sub Form_Resize ()
  501.   On Error Resume Next
  502.   'resize grid to window
  503.   If WindowState <> 1 Then   'not minimized
  504.     cGrid.Height = Height - 900
  505.     cGrid.Width = Width - 100
  506.   End If
  507. End Sub
  508. Sub Form_Unload (Cancel As Integer)
  509.   On Error Resume Next
  510.   'unload the find form
  511.   Unload FFindForm
  512.   'close the associated dynaset
  513.   FDS.Close
  514.   MsgBar NULL_STR, False
  515. End Sub
  516. Sub MoreButton_Click ()
  517.   Dim ret As Integer   'return value from loadgrid
  518.   On Error Resume Next
  519.   MsgBar "Getting more records", True
  520.   If FDS.EOF <> True Then
  521.     SetHourglass Me
  522.     ret = LoadGridSS(cGrid, FDS, FDynSt, gwMaxGridRows, FCurrentRow)
  523.     If ret = False Then
  524.       'failed so bail out of form
  525.       FDS.Close
  526.       Unload Me
  527.     End If
  528.     'set new current row
  529.     FCurrentRow = FCurrentRow + ret
  530.     ResetMouse Me
  531.   End If
  532.   MsgBar NULL_STR, False
  533. End Sub
  534. Sub NextButton_Click ()
  535.    Dim c As Integer      'current column
  536.    On Error GoTo GoNextError
  537.    c = cGrid.Col
  538.    cGrid.Col = 0
  539.    If Len(cGrid.Text) = 0 Then
  540.      Beep
  541.    ElseIf cGrid.Row = gwMaxGridRows Then
  542.      MoreButton_Click
  543.    Else
  544.      cGrid.SetFocus
  545.      SendKeys "{Down}"
  546.    End If
  547.    cGrid.Col = c
  548.    GoTo GoNextEnd
  549. GoNextError:
  550.    ShowError
  551.    Resume GoNextEnd
  552. GoNextEnd:
  553. End Sub
  554. 'needed for multi-user situations so
  555. 'new records can be viewed imediately
  556. Sub RefreshButton_Click ()
  557.    Dim numbrows As Long
  558.    On Error GoTo RefreshError
  559.    MsgBar "Reopening Dynaset", True
  560.    SetHourglass Me
  561.    Set FDS = gCurrentDB.CreateSnapshot(FDS.Name)
  562.    FNumbRows = GetNumbRecsSS(FDS)
  563.    If FNumbRows = -1 Then
  564.      'error occurred but go on anyway
  565.      'because row count is non-critical
  566.      caption = "SnapShot: " & FTblName
  567.      numbrows = gwMaxGridRows
  568.      FCurrentRow = numbrows
  569.    ElseIf FNumbRows = 0 Then
  570.      Beep
  571.      MsgBox "No Records found!", 48
  572.      ResetMouse Me
  573.      Unload Me
  574.      Exit Sub
  575.    ElseIf FNumbRows > gwMaxGridRows Then
  576.      caption = "SnapShot: " & FTblName & " [" & CStr(FNumbRows) & " total rows]"
  577.      numbrows = gwMaxGridRows
  578.      FCurrentRow = numbrows
  579.    Else
  580.      numbrows = FNumbRows
  581.      caption = "SnapShot: " & FTblName & " [" & CStr(FNumbRows) & " rows]"
  582.    End If
  583.    If LoadGridSS(cGrid, FDS, FDynSt, numbrows, 0) = False Then
  584.      Unload Me
  585.      Exit Sub
  586.    End If
  587.   GoTo RefreshEnd
  588. RefreshError:
  589.   ShowError
  590.   Resume RefreshEnd
  591. RefreshEnd:
  592.   ResetMouse Me
  593.   MsgBar NULL_STR, False
  594. End Sub
  595. Sub SortButton_Click ()
  596.   On Error GoTo SortErr
  597.   Dim ds1 As Snapshot, ds2 As Snapshot
  598.   Dim SortStr As String
  599.   Dim numbrows As Long    'local number of rows
  600.   Set ds1 = FDS            'save the dynaset
  601.   SortStr = InputBox("Enter Sort Column:")
  602.   If Len(SortStr) = 0 Then Exit Sub
  603.   FDS.Sort = SortStr
  604.   Set ds2 = FDS.CreateSnapshot()            'establish the Sort
  605.   Set FDS = ds2            'assign back to original dynaset object
  606.   'everything must be okay so redisplay form on 1st record
  607.   FNumbRows = GetNumbRecsSS(FDS)          'query numb of recs
  608.    If FNumbRows = -1 Then
  609.      'error occurred but go on anyway
  610.      'because row count is non-critical
  611.      caption = "SnapShot: " & FTblName
  612.      numbrows = gwMaxGridRows
  613.      FCurrentRow = numbrows
  614.    ElseIf FNumbRows = 0 Then
  615.      Beep
  616.      MsgBox "No Records found!", 48
  617.      ResetMouse Me
  618.      Unload Me
  619.      Exit Sub
  620.    ElseIf FNumbRows > gwMaxGridRows Then
  621.      caption = "SnapShot: " & FTblName & " [" & CStr(FNumbRows) & " total rows]"
  622.      numbrows = gwMaxGridRows
  623.      FCurrentRow = numbrows
  624.    Else
  625.      numbrows = FNumbRows
  626.      caption = "SnapShot: " & FTblName & " [" & CStr(FNumbRows) & " rows]"
  627.    End If
  628.   If LoadGridSS(cGrid, FDS, FDynSt, numbrows, 0) = False Then
  629.     Unload Me
  630.     Exit Sub
  631.   End If
  632.   GoTo SortEnd
  633. SortErr:
  634.   ShowError
  635.   Set FDS = ds1            're-assign back to original
  636.   Resume SortEnd
  637. SortEnd:
  638. End Sub
  639.